package com.ruoyi.kws.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import io.lettuce.core.RedisConnectionStateAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.kws.mapper.CountDataMapper;
import com.ruoyi.kws.domain.CountData;
import com.ruoyi.kws.service.ICountDataService;

/**
 * 数据统计Service业务层处理
 *
 * @author wfc
 * @date 2025-02-01
 */
@Service
public class CountDataServiceImpl implements ICountDataService
{
    @Autowired
    private CountDataMapper countDataMapper;

    /**
     * 查询数据统计
     *
     * @param id 数据统计主键
     * @return 数据统计
     */
    @Override
    public CountData selectCountDataById(Long id)
    {
        return countDataMapper.selectCountDataById(id);
    }

    /**
     * 查询数据统计列表
     *
     * @param countData 数据统计
     * @return 数据统计
     */
    @Override
    public List<CountData> selectCountDataList(CountData countData)
    {
        return countDataMapper.selectCountDataList(countData);
    }

    /**
     * 新增数据统计
     *
     * @param countData 数据统计
     * @return 结果
     */
    @Override
    public int insertCountData(CountData countData)
    {

        CountData ret = new CountData();
        ret.setRq(countData.getRq());
        List<CountData> countDataList = countDataMapper.selectCountDataList(ret);
        if(countDataList.size()>0){
            return 0;
        }
        countData.setCreateTime(DateUtils.getNowDate());
        return countDataMapper.insertCountData(countData);
    }

    /**
     * 修改数据统计
     *
     * @param countData 数据统计
     * @return 结果
     */
    @Override
    public int updateCountData(CountData countData)
    {
        countData.setUpdateTime(DateUtils.getNowDate());
        return countDataMapper.updateCountData(countData);
    }

    /**
     * 批量删除数据统计
     *
     * @param ids 需要删除的数据统计主键
     * @return 结果
     */
    @Override
    public int deleteCountDataByIds(Long[] ids)
    {
        return countDataMapper.deleteCountDataByIds(ids);
    }

    /**
     * 删除数据统计信息
     *
     * @param id 数据统计主键
     * @return 结果
     */
    @Override
    public int deleteCountDataById(Long id)
    {
        return countDataMapper.deleteCountDataById(id);
    }
}
